package LeetCodeHot100TopInterview;

public class Q101_IsSymmetricTree {

    //是否对称二叉树 ==> 翻转二叉树
    //同剑指offerQ28 ==> 当时翻车了
    public boolean isSymmetric(TreeNode root) {
        if (root == null){
            return true;
        }
        return isEqual(root.left, root.right);
    }

    //判断两个节点是否相等
    public boolean isEqual(TreeNode root1, TreeNode root2){
        if (root1 == null && root2 == null){
            return true;
        }
        if (root1 == null || root2 == null || root1.val != root2.val){
            return false;
        }
        return isEqual(root1.left, root2.right) && isEqual(root1.right, root2.left);
    }

}
